<link rel="stylesheet" href="/opebs/css/bootstrap.min.css">
<link rel="stylesheet" href="/opebs/date/css/bootstrap-datetimepicker.css">
<link rel="stylesheet" href="/opebs/css/bootstrap-select.css">
<script src="/opebs/js/jquery.min.js"></script>
<script src="/opebs/js/bootstrap.min.js"></script>
<script src="/opebs/js/bootstrap-select.js"></script>
<script src="/lib/jquery.form.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<link rel="stylesheet" href="/opebs/date/css/bootstrap-datetimepicker.min.css">
<script src="/opebs/date/js/bootstrap-datetimepicker.min.js"></script>


<link href="/lib/ueditor/themes/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="/lib/ueditor/js/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/lib/ueditor/js/editor_api.js"></script>
<script type="text/javascript" src="/lib/ueditor/lang/zh-cn/zh-cn.js"></script>



<#include "/common/h-ui-base-css.html">
<#include "/common/validation-js.html">
<body>
    <div class="page-container" >
        <form action="" method="post" class="form form-horizontal" id="form-project-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目编号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proId!}" style="background-color: #8eaf84" placeholder=""  readonly id="proId">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proName!}" style="background-color: #8eaf84" placeholder=""  readonly id="proName">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目类别：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proCategory!}" style="background-color: #8eaf84" placeholder=""  readonly id="proCategory">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目状态：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${proState!}"style="background-color: #8eaf84" placeholder=""  readonly id="proState">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目所属公司：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proCompany!}" style="background-color: #8eaf84" placeholder=""  readonly id="proCompany">
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目投资对象：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proInvestment!}" id="proInvestment" name="proInvestment">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目预计投资金额：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proInvestmentMoney!}" id="proInvestmentMoney" name="proInvestmentMoney">
                </div>
            </div>

            <!-->
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">投决会会议纪要：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proJcVotintMeet!}" id="proJcVotintMeet" name="proJcVotintMeet">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">董事会会议纪要：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proJcDongShiHui!}" id="proJcDongShiHui" name="proJcDongShiHui">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">集团董事会会议纪要：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proJcJiTuan!}" id="proJcJiTuan" name="proJcJiTuan">
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目投资方式：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select id="proJueCeInvestType" name="proJueCeInvestType" class="selectpicker form-control"  data-live-search="true"
                            onchange="show_proJueCeInvestType(this.options[this.options.selectedIndex].value)">
                        <option>请选择</option>
                        <#if projectInvestType??>
                            <#list projectInvestType as m>
                                 <option  value="${m.key}" <#if project.proJueCeInvestType??><#if project.proJueCeInvestType=m.key>selected</#if></#if> >${m.text}</option>
                            </#list>
                        </#if>
                    </select>
                </div>
            </div>

            <div class="row cl" style="display: none " id="proJiJinScaleDiv">
                <label class="form-label col-xs-4 col-sm-2">基金规模：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proJiJinScale!}" id="proJiJinScale" name="proJiJinScale">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目投资主体：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proJueCeInvestCorpus!}" id="proJueCeInvestCorpus" name="proJueCeInvestCorpus">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">项目尽调获取方式：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select id="proJueCeReport" name="proJueCeReport" class="selectpicker form-control"  data-live-search="true"
                            onchange="show_sub(this.options[this.options.selectedIndex].value)">
                        <option>请选择</option>
                        <#if projectInvestReport??>
                            <#list projectInvestReport as m>
                                <option  value="${m.key}" <#if project.proJueCeReport??><#if project.proJueCeReport=m.key>selected</#if></#if> >${m.text}</option>
                            </#list>
                        </#if>
                    </select>

                    <p class="form-control-static"><button class="btn btn-primary" data-toggle="button" onclick="up()">上传</button></p>
                </div>
            </div>

            <#--根据项目尽调方式进行显示-->
            <div class="row cl" style="display: none " id="proBelieveReasonDiv">
                <label class="form-label col-xs-4 col-sm-2">采信原因：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proBelieveReason!}" id="proBelieveReason" name="proBelieveReason">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proThirdOrgNameDiv">
                <label class="form-label col-xs-4 col-sm-2">第三方机构名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proThirdOrgName!}" id="proThirdOrgName" name="proThirdOrgName">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proReportMoneyDiv">
                <label class="form-label col-xs-4 col-sm-2">尽调报告费用：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proReportMoney!}" id="proThirdOrgName" name="proReportMoney">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proLawOrgDiv">
                <label class="form-label col-xs-4 col-sm-2">法律尽调机构：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proLawOrg!}" id="proLawOrg" name="proLawOrg">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proLawMoneyDiv">
                <label class="form-label col-xs-4 col-sm-2">法律尽调机构费用：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proLawMoney!}" id="proLawMoney" name="proLawMoney">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proFinanceOrgDiv">
                <label class="form-label col-xs-4 col-sm-2">财务尽调机构：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proFinanceOrg!}" id="proThirdOrgName" name="proFinanceOrg">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proFinanceMoneyDiv">
                <label class="form-label col-xs-4 col-sm-2">财务尽调机构费用：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proFinanceMoney!}" id="proFinanceMoney" name="proFinanceMoney">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proAssetsOrgDiv">
                <label class="form-label col-xs-4 col-sm-2">资产评估机构：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proAssetsOrg!}" id="proAssetsOrg" name="proAssetsOrg">
                </div>
            </div>

            <div class="row cl" style="display: none " id="proAssetsMoneyDiv">
                <label class="form-label col-xs-4 col-sm-2">资产评估费用：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proAssetsMoney!}" id="proAssetsMoney" name="proAssetsMoney">
                </div>
            </div>

            <div class="row cl" >
                <label class="form-label col-xs-4 col-sm-2">其他重要事项：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="${project.proImportantNotes!}" id="proImportantNotes" name="proImportantNotes">
                </div>
            </div>

            <#--<div class="row cl">-->
                <#--<label class="form-label col-xs-4 col-sm-2">其他重要事项：</label>-->
                <#--<div class="formControls col-xs-8 col-sm-9">-->
                    <#--<script type="text/plain" id="myEditor" name="proImportantNotes" style="width:1000px;height:240px;">${project.proImportantNotes!}</script>-->
                <#--</div>-->
            <#--</div>-->


            <div class="row cl" >
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button  class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
                </div>
            </div>
            <input type="text" hidden id="proJueceFlag" name="proJueceFlag" value="1">
            <input type="text" hidden id="id" name="id" value="${project.id}">
        </form>
    </div>
</body>

                        <#--<script type="text/javascript">-->

                    <#--var um = UM.getEditor('myEditor',{-->
                        <#--//这里可以选择自己需要的工具按钮名称,此处仅选择如下七个-->
                        <#--toolbar:['fullscreen source undo redo bold italic underline'],-->
                        <#--//focus时自动清空初始化时的内容-->
                        <#--autoClearinitialContent:false,-->
                        <#--//关闭字数统计-->
                        <#--wordCount:false,-->
                        <#--//关闭elementPath-->
                        <#--elementPathEnabled:false,-->
                        <#--//默认的编辑区域高度-->
                        <#--initialFrameHeight:300-->
                        <#--//更多其他参数，请参考umeditor.config.js中的配置项-->
                    <#--});-->
                    <#--</script>-->

<script>
    //组建基金-基金规模
    function show_proJueCeInvestType(val){
        if(val == '组建基金'){
            $('#proJiJinScaleDiv').css('display','');
        }else {
            $('#proJiJinScaleDiv').css('display','none');
        }
    }

    //采信第三方、自己组织尽调
    function show_sub(val){
        if(val == "采信第三方"){
            $('#proBelieveReasonDiv').css('display','');
            $('#proThirdOrgNameDiv').css('display','');
            $('#proReportMoneyDiv').css('display','');

            $('#proLawOrgDiv').css('display','none');
            $('#proLawMoneyDiv').css('display','none');
            $('#proFinanceOrgDiv').css('display','none');
            $('#proFinanceMoneyDiv').css('display','none');
            $('#proAssetsOrgDiv').css('display','none');
            $('#proAssetsMoneyDiv').css('display','none');
        }else if(val == "自己组织尽调"){
            $('#proLawOrgDiv').css('display','');
            $('#proLawMoneyDiv').css('display','');
            $('#proFinanceOrgDiv').css('display','');
            $('#proFinanceMoneyDiv').css('display','');
            $('#proAssetsOrgDiv').css('display','');
            $('#proAssetsMoneyDiv').css('display','');

            $('#proBelieveReasonDiv').css('display','none');
            $('#proThirdOrgNameDiv').css('display','none');
            $('#proReportMoneyDiv').css('display','none');

        }else {
            $('#proBelieveReasonDiv').css('display','none');
            $('#proThirdOrgNameDiv').css('display','none');
            $('#proReportMoneyDiv').css('display','none');
            $('#proLawOrgDiv').css('display','none');
            $('#proLawMoneyDiv').css('display','none');
            $('#proFinanceOrgDiv').css('display','none');
            $('#proFinanceMoneyDiv').css('display','none');
            $('#proAssetsOrgDiv').css('display','none');
            $('#proAssetsMoneyDiv').css('display','none');
        }
    }


    function up(){
        var id = $('#id').val();
        var proJueCeReport = $("#proJueCeReport option:selected").val();
        var url = '';
        if(proJueCeReport == '采信第三方'){
            url = '/common-upload-jueceEdit0/'+id+'/'+2;
        }else if(proJueCeReport == '自己组织尽调'){
            url = '/common-upload-jueceEdit1/'+id+'/'+2;
        }else {
            var state = -1;
            url = '/common-upload/'+id+'/'+state;
        }
        var index = layer.open({
            title:'资料上传',
            type: 2,
            area: ['700px', '450px'],
            fixed: true, //不固定
            maxmin: true,
            content: url
        });
        layer.full(index);
    }

    //页面加载初始化尽调方式
    $(document).ready(function(){
        var proJueCeReport = $('#proJueCeReport').val();
        show_sub(proJueCeReport);
        var proJueCeInvestType = $('#proJueCeInvestType').val();
        show_proJueCeInvestType(proJueCeInvestType);
    });

</script>

<script type="text/javascript">
    $(function(){
        $("#proInvestmentTime").datetimepicker({
            format:'yyyy-mm-dd',  //格式  如果只有yyyy-mm-dd那就是0000-00-00
            autoclose:true,//选择后是否自动关闭
            minView:2,//最精准的时间选择为日期  0-分 1-时 2-日 3-月
            language:  'zh-CN', //中文
            weekStart: 1, //一周从星期几开始
            todayBtn:  1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            // daysOfWeekDisabled:"1,2,3", //一周的周几不能选 格式为"1,2,3"  数组格式也行
            todayBtn : true,  //在底部是否显示今天
            todayHighlight :true, //今天是否高亮显示
            keyboardNavigation:true, //方向图标改变日期  必须要有img文件夹 里面存放图标
            showMeridian:false,  //是否出现 上下午
            initialDate:new Date()
            //startDate: "2017-01-01" //日期开始时间 也可以是new Date()只能选择以后的时间
        }).on("changeDate",function(){
            var start = $("#start").val();
        });

    });
</script>

<script type="text/javascript">
    $("#form-project-add").validate({
        rules:{
            proInvestment:{
                required:true
            },
            proInvestmentTime:{
                required:true
            } ,
            proInvestmentMoney:{
                required:true,
                number:true
            } ,
            proProportion:{
                required:true
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            var id = ${project.id!};
            // var proImportantNotes = um.getPlainTxt();
            var proImportantNotes = $('#proImportantNotes').val();
            $(form).ajaxSubmit({
                type: 'post',
                url: "/project-ins-upd-del/"+id ,
                data :$("form-project-add").serialize()+'&proImportantNotes='+proImportantNotes,
                async:false,
                success: function(data){
                    layer.msg('添加成功!',{icon:1,time:1000});
                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    layer.msg('error!',{icon:1,time:1000});
                }
            });
            var index = parent.layer.getFrameIndex(window.name);
            var refreshFlag = ${refreshFlag!};
            if(refreshFlag == 0){
                var handler = '/project-list/2/1/20';
                parent.$('#project_table').datagrid('options').url = handler;
                parent.$('#project_table').datagrid('reload');
            }else if(refreshFlag == 1){
                parent.location.reload();
            }
            parent.layer.close(index);
        }
    });
</script>
